package com.ideal.dao;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.ideal.mapper.IDeptDAO;
import com.ideal.po.Dept;
@Repository("deptdao1")
public class DeptDAO implements IDeptDAO {
	@Resource
	private SqlSessionTemplate session;


	public List<Dept> findall() {
		List<Dept> list = 
				session.selectList("com.ideal.mapper.IDeptDAO.findall");
		return list;
	}

	public void adddept(Dept dept) {
		session.insert("com.ideal.mapper.IDeptDAO.adddept", dept);
	}

	public Dept findById(int deptno) {
		Dept d=session.selectOne("com.ideal.mapper.IDeptDAO.findById", deptno);
		System.out.println(d.getDeptno()+"  "+d.getDname()+"  "+d.getLoc());
		return d;
	}

	public Dept delete(Dept dept) {
		session.delete("com.ideal.mapper.IDeptDAO.delete",dept);
		return null ;
	}

	public void merge(Dept dept) {
		session.update("com.ideal.mapper.IDeptDAO.merge",dept);
		
	}

	

}
